<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath }"/>
<%@taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>固定资产管理系统</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
	<meta content="" name="author" />
	<meta name="MobileOptimized" content="320">
	<!-- BEGIN GLOBAL MANDATORY STYLES -->          
	<link href="${ctx}/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
	<!-- END GLOBAL MANDATORY STYLES -->
	<!-- BEGIN THEME STYLES --> 
	<link href="${ctx}/assets/css/style-metronic.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/css/style.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/css/plugins.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/css/themes/light.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/css/custom.css" rel="stylesheet" type="text/css"/>
	<link rel="stylesheet" type="text/css" href="${ctx}/assets/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" />
	<link rel="stylesheet" type="text/css" href="${ctx}/assets/plugins/bootstrap-datetimepicker/css/datetimepicker.css" />
	<link rel="stylesheet" type="text/css" href="${ctx}/assets/plugins/jquery-multi-select/css/multi-select.css" />
	<link href="${ctx }/css/custom.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx }/assets/plugins/jquery-file-upload/css/jquery.fileupload-ui.css" rel="stylesheet" />
	<link href="${ctx}/frontend/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>   
   	<link href="${ctx}/frontend/assets/css/pages/portfolio.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/frontend/assets/plugins/fancybox/source/jquery.fancybox.css" rel="stylesheet" />              
    <link rel="stylesheet" href="${ctx}/frontend/assets/plugins/revolution_slider/css/rs-style.css" media="screen">
    <link rel="stylesheet" href="${ctx}/frontend/assets/plugins/revolution_slider/rs-plugin/css/settings.css" media="screen"> 
    <link href="${ctx}/frontend/assets/plugins/bxslider/jquery.bxslider.css" rel="stylesheet" />       
	<link rel="stylesheet" type="text/css" href="${ctx}/assets/plugins/bootstrap-datepicker/css/datepicker.css" />
	<link rel="stylesheet" type="text/css" href="${ctx}/assets/plugins/bootstrap-timepicker/compiled/timepicker.css" />
	<!-- END THEME STYLES -->	
	<link rel="shortcut icon" href="favicon.ico" />
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed page-full-width">
	<!-- BEGIN HEADER -->   
	<%@include file="../include/header.jsp" %>
	<!-- END HEADER -->
	
	<!-- BEGIN CONTAINER -->
	<div class="page-container">
		<div class="page-content">			
			<!-- BEGIN PAGE HEADER-->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN PAGE TITLE & BREADCRUMB-->
					<h3 class="page-title">
						物资采购登记
					</h3>
					<!-- END PAGE TITLE & BREADCRUMB-->
				</div>
			</div>
			<!-- END PAGE HEADER-->
			<!-- BEGIN PAGE CONTENT-->          
			<div class="row">
				<div class="col-md-12">
					<div style="text-align:right;">
						<button type="button" id="tijiao" class="btn blue">采购信息提交</button>&nbsp;&nbsp;
						<button type="button" id="quXiao" class="btn default">取消</button>
					</div>
					<!-- BEGIN SAMPLE TABLE PORTLET-->
				</div>
			</div>
			<br>
			<div class="row">
				<div class="col-md-12">
					<div class="portlet box green">
						<div class="portlet-title">
							<div class="caption"><i class="fa fa-reorder"></i>采购信息</div>
							<div class="tools">
								<a href="javascript:;" class="collapse"></a>	
							</div>
						</div>
						<div class="portlet-body form">
							<form action="" id="caiGouForm" class="form-horizontal">
								<br>
								<div class="col-md-12">
									<input type="hidden" id="wuZiIds" name="wuZiIds" value="">
									<input type="hidden" id="heTong" name="heTong" value="">
									<input type="hidden" id="fuJian" name="fuJian" value="">
									<div class="row">
										<div class="form-group">												
											<label class="col-md-2 control-label">采购途径</label>
											<div class="col-md-4">
												<input type="text" class="form-control" id="tuJing" name="tuJing" placeholder="采购途径">
											</div>
											<label class="col-md-2 control-label">采购方式</label>
											<div class="col-md-4">
												<select name="fangShi" id="fangShi" class="form-control">
													<option value="1">招标</option>
													<option value="2">询价</option>
													<option value="3">比选</option>
													<option value="4">竞争性谈判</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label">价格</label>
											<div class="col-md-4">
												<input type="text" class="form-control" id="jiaGe" name="jiaGe" placeholder="价格">
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label">备注</label>
											<div class="col-md-10">
												<input type="text" class="form-control" id="beiZhu" name="beiZhu" placeholder="备注">
											</div>
										</div>
									</div>
								</div>
							</form>
							<form action="" class="form-horizontal">
								<div class="col-md-12">
									<div class="row">
										<div class="form-group">												
											<label class="col-md-2 control-label">合同</label>
											<div class="col-md-7" id="heTongList" style="margin-top:5px">
											</div>
											<div class="col-md-1">
												<a class="btn green" data-toggle="modal" href="#uploadFJ" id="upHeTong">上传合同</a>
											</div>
											<div class="col-md-2">
												<a class="btn blue" data-toggle="modal" href="#guanLianXZ" id="xzHeTong">关联已有</a>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label">附件</label>
											<div class="col-md-7" id="fuJianList" style="margin-top:5px">
											</div>
											<div class="col-md-1">
												<a class="btn green" data-toggle="modal" href="#uploadFJ" id="upFuJian">上传附件</a>
											</div>
											<div class="col-md-2">
												<a class="btn blue" data-toggle="modal" href="#guanLianXZ" id="xzFuJian">关联已有</a>
											</div>
										</div>
									</div>
								</div>
							</form>
							<!-- END FORM--> 
						</div>
					</div>
					<div class="portlet box blue">
						<div class="portlet-title">
							<div class="caption"><i class="fa fa-reorder"></i>物资信息</div>
							<div class="tools">
								<a href="javascript:;" class="collapse"></a>	
							</div>
						</div>
						<div class="portlet-body form">
							<form action="" class="form-horizontal" id="wuZiForm">
								<br>
								<div class="col-md-12">
									<input type="hidden" name="sqIds" value="${sqIds }">
									<div class="row">
										<div class="form-group">												
											<label class="col-md-2 control-label">物料编码</label>
											<div class="col-md-4">
												<input type="text" class="form-control" id="wuLiaoBM" name="wuLiaoBM" placeholder="物料编码">
											</div>
											<label class="col-md-2 control-label">物资名称</label>
											<div class="col-md-4">
												<input type="text" class="form-control" id="wuZiMC" name="wuZiMC" placeholder="物资名称">
											</div>
										</div>
									</div>
									<div class="row">
										<div class="form-group">
											<label class="col-md-2 control-label">物资品牌</label>
											<div class="col-md-4">
												<input type="text" class="form-control" name="pinPai" placeholder="物资品牌">
											</div>											
											<label class="col-md-2 control-label">规格型号</label>
											<div class="col-md-4">
												<input type="text" class="form-control" id="guiGeXH" name="guiGeXH" placeholder="规格型号">
											</div>
										</div>
									</div>
									<div class="row">
										<div class="form-group">												
											<label class="col-md-2 control-label">生产厂家</label>
											<div class="col-md-4">
												<input type="text" class="form-control" name="shengChanCJ" placeholder="生产厂家">
											</div>
											<label class="col-md-2 control-label">物资原值</label>
											<div class="col-md-2">
												<input type="text" class="form-control" name="wuZiYZ" placeholder="物资原值">
											</div>
											<div class="col-md-2">
												<select name="biZhongId" class="form-control">
													<c:forEach items="${biZhong }" var="u">
														<option value="${u.id}">${u.biZhongMC}</option>
													</c:forEach>
												</select>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="form-group">
											<label class="col-md-2 control-label">物资类别</label>
											<div class="col-md-2">
												<select id="wuZiLB1" class="form-control">
													<option value="">请选择...</option>
													<c:forEach items="${wuZiLB1 }" var="u">
														<option value="${u.id}">${u.leibieMC}</option>
													</c:forEach>
												</select>
											</div>
											<div class="col-md-2">
												<select name="wuZiLBId" id="wuZiLB2" class="form-control"></select>
											</div>
											<label class="col-md-2 control-label">物资类型</label>
											<div class="col-md-4">
												<select name="wuZiLX" id="wuZiLX" class="form-control">
													<option value="1">固定资产</option>
													<option value="2">低值易耗品</option>
												</select>
											</div>											
										</div>
									</div>
									<div class="row">
										<div class="form-group">
											<label class="col-md-2 control-label">供应商名称</label>
											<div class="col-md-9">
												<input type="text" class="form-control" name="gongYingShangMC" placeholder="供应商名称">
											</div>
										</div>
									</div>
									<div class="row">
										<div class="form-group">
											<label class="col-md-2 control-label">购买日期</label>
											<div class="col-md-4">
												<div class="input-group input-medium date date-picker" data-date-format="yyyy-mm-dd">
													<input type="text" class="form-control" name="gouMaiRQStr" value="${dangQianRQ }" readonly>
													<span class="input-group-btn">
													<button class="btn default" type="button"><i class="fa fa-calendar"></i></button>
													</span>
												</div>
											</div>
										</div>
									</div>
								</div>
							</form>
							<!-- END FORM--> 
						</div>
					</div>
				</div>
			</div>
			<!-- END PAGE CONTENT-->
		</div>
		<!-- END PAGE -->
	</div>
	<!-- END CONTAINER -->
	<!-- BEGIN FOOTER -->
	<%@include file="../include/footer.jsp" %>
	<!-- END FOOTER -->
	<div class="modal fade" id="guanLianXZ" tabindex="-1" role="basic" aria-hidden="true">
		<div class="modal-dialog modal-wide">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
					<h4 class="modal-title">选择文件</h4>
				</div>
				<div class="modal-body" id="fileListBody">
				</div>
				<div class="modal-footer">
					<button type="button" class="btn blue" data-dismiss="modal" onclick="xuanZeQueDing()">确定</button>
					<button type="button" class="btn default" data-dismiss="modal">关闭</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<div class="modal fade" id="uploadFJ" tabindex="-1" role="basic" aria-hidden="true">
		<div class="modal-dialog modal-wide">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
					<h4 class="modal-title">上传文件</h4>
				</div>
				<div class="modal-body" id="fileUploadBody">
				</div>
				<div class="modal-footer">
					<button type="button" class="btn blue" data-dismiss="modal">关闭</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<script id="template-upload" type="text/x-tmpl">
		{% for (var i=0, file; file=o.files[i]; i++) { %}
		    <tr class="template-upload fade">
		        <td>
		            <span class="preview"></span>
		        </td>
		        <td>
		            <p class="name">{%=file.name%}</p>
		            {% if (file.error) { %}
		                <div><span class="label label-danger">错误</span> {%=file.error%}</div>
		            {% } %}
		        </td>
		        <td>
		            <p class="size">{%=o.formatFileSize(file.size)%}</p>
		            {% if (!o.files.error) { %}
		                <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
		                <div class="progress-bar progress-bar-success" style="width:0%;"></div>
		                </div>
		            {% } %}
		        </td>
		        <td>
		            {% if (!o.files.error && !i && !o.options.autoUpload) { %}
		                <button class="btn blue start">
		                    <i class="fa fa-upload"></i>
		                    <span>上传</span>
		                </button>
		            {% } %}
		            {% if (!i) { %}
		                <button class="btn red cancel">
		                    <i class="fa fa-ban"></i>
		                    <span>取消</span>
		                </button>
		            {% } %}
		        </td>
		    </tr>
		{% } %}
	</script>
	<!-- The template to display files available for download -->
	<script id="template-download" type="text/x-tmpl">
		{% for (var i=0, file; file=o.files[i]; i++) { %}
		    <tr class="template-download fade">
		        <td>
		            <span class="preview">
		                {% if (file.thumbnailUrl) { %}
		                    <a href="${ctx}{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery>
		                    	<img src="{%=file.fileIcon%}" style="width:32px;height:32px;">
		                    </a>
		                {% } %}
		            </span>
		        </td>
		        <td>
		            <p class="name">
		                {% if (file.url) { %}
		                    <a href="${ctx}{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" ${ctx}{%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
		                {% } else { %}
		                    <span>{%=file.name%}</span>
		                {% } %}
		            </p>
		            {% if (file.error) { %}
		                <div><span class="label label-danger">错误</span> {%=file.error%}</div>
		            {% } %}
		        </td>
		        <td>
		            <span class="size">{%=o.formatFileSize(file.size)%}</span>
		        </td>
		        <td>
		            {% if (file.deleteUrl) { %}
		                <button onclick="delFuJian('{%=file.fuJianId%}','{%=file.type%}')" class="btn red delete" data-type="{%=file.deleteType%}" data-url="${ctx}{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
		                    <i class="fa fa-trash-o"></i>
		                    <span>删除</span>
		                </button>
		            {% } else { %}
		                <button class="btn yellow cancel">
		                    <i class="fa fa-ban"></i>
		                    <span>取消</span>
		                </button>
		            {% } %}
		        </td>
		    </tr>
		{% } %}
	</script>
	<script src="${ctx}/assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
	<script src="${ctx}/assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>    
	<script src="${ctx}/assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
	<script src="${ctx}/assets/plugins/bootstrap-hover-dropdown/twitter-bootstrap-hover-dropdown.min.js" type="text/javascript" ></script>
	<script src="${ctx}/assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
	<script src="${ctx}/assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>  
	<script src="${ctx}/assets/plugins/jquery.cookie.min.js" type="text/javascript"></script>
	<script src="${ctx}/assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript" ></script>
	<script src="${ctx}/assets/plugins/jquery-validation/dist/jquery.validate.min.js" type="text/javascript"></script>
	<script src="${ctx}/assets/scripts/form-components.js"></script>
	<script type="text/javascript" src="${ctx}/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
	<script type="text/javascript" src="${ctx}/assets/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
	<script type="text/javascript" src="${ctx}/assets/plugins/bootstrap-datepicker/js/locales/bootstrap-datepicker.zh-CN.js"></script>
	<script type="text/javascript" src="${ctx}/assets/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
	<script type="text/javascript" src="${ctx}/assets/plugins/clockface/js/clockface.js"></script>
	<script type="text/javascript" src="${ctx}/assets/plugins/bootstrap-daterangepicker/moment.min.js"></script>
	<script type="text/javascript" src="${ctx}/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
	<script type="text/javascript" src="${ctx}/frontend/assets/plugins/revolution_slider/rs-plugin/js/jquery.themepunch.plugins.min.js"></script>
    <script type="text/javascript" src="${ctx}/frontend/assets/plugins/revolution_slider/rs-plugin/js/jquery.themepunch.revolution.min.js"></script> 
    <script type="text/javascript" src="${ctx}/frontend/assets/plugins/bxslider/jquery.bxslider.min.js"></script>    
    <script type="text/javascript" src="${ctx }/assets/plugins/jquery.input-ip-address-control-1.0.min.js"></script>
    <script type="text/javascript" src="${ctx }/assets/plugins/jquery-multi-select/js/jquery.multi-select.js"></script>
    <script type="text/javascript" src="${ctx }/assets/plugins/jquery-inputmask/jquery.inputmask.bundle.min.js"></script>
    <script type="text/javascript" src="${ctx}/assets/plugins/select2/select2.min.js"></script>
    <script type="text/javascript" src="${ctx}/assets/plugins/fuelux/js/spinner.min.js"></script>
    <script src="${ctx}/assets/plugins/bootstrap-touchspin/bootstrap.touchspin.js" type="text/javascript"></script>
    <script src="${ctx }/assets/plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript" ></script>
    <script src="${ctx }/assets/plugins/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/vendor/tmpl.min.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/vendor/load-image.min.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/vendor/canvas-to-blob.min.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/jquery.iframe-transport.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/jquery.fileupload.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/jquery.fileupload-process.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/jquery.fileupload-image.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/jquery.fileupload-audio.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/jquery.fileupload-video.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/jquery.fileupload-validate.js"></script>
	<script src="${ctx }/assets/plugins/jquery-file-upload/js/jquery.fileupload-ui.js"></script>
	<script src="${ctx }/js/form-fileupload.js"></script>
    <script src="${ctx}/frontend/assets/scripts/index.js"></script>
	<!-- END CORE PLUGINS -->
	<script src="${ctx}/assets/scripts/app.js"></script>
	
	<script>
		jQuery(document).ready(function() {       
		   // initiate layout and plugins
		   App.init();
		   FormComponents.init();
		});
		
		$('#wuZiLB1').bind("click",function(){
			$.ajax({
				url:"${ctx}/system/getAllWuZiLB2.do?id="+$('#wuZiLB1').val(),
				type:"POST",
				success:function(data){
					$('#wuZiLB2').html(data);
				}
			});
		});
		
		$('#quXiao').bind("click",function(){
			window.close();
		});
		
		$('#wuLiaoBM').bind("change",function(){
			$.ajax({
				type:"POST",
				data:{
					"wuLiaoBM":$('#wuLiaoBM').val()
				},
				url:"${ctx}/wuzi/getBianMa.do",
				dataType:"json",
				success:function(data){
					if(data.zhuangTai=="1"){
						$('#wuZiMC').val(data.wuLiaoMC);
						$('#guiGeXH').val(data.guiGeXH);
					}else if(data.zhuangTai=="2"){
						$('#wuZiMC').val('');
						$('#guiGeXH').val('');
					}
				}
			});			
		});
		
		function validateForm() {
			//validate方法参数可选  
			return $("#wuZiForm").validate({
				errorElement: 'span', //default input error message container
	            errorClass: 'help-block', // default input error message class
	            focusInvalid: false, // do not focus the last invalid input
				rules : {
					wuZiYZ : {
						required : true,
						number : true
					},
					wuZiMC : {
						required : true						
					},
					wuZiLBId : {
						required : true
					},
					wuLiaoBM : {
						required : true
					},
					gouMaiRQStr : {
						required : true
					}
				},
				messages : {					
					wuZiYZ : {
						required : '请输入物资原值',
						number : '请输入数值'
					},
					wuZiMC : {
						required : '请输入物资名称'
					},
					wuZiLBId : {
						required : '请选择物资类别'
					},
					wuLiaoBM : {
						required : '请输入物料编码'
					},
					gouMaiRQStr : {
						required : '请选择购买日期'
					}
				},
				highlight: function (element) { // hightlight error inputs
	                $(element)
	                    .closest('.form-group').addClass('has-error'); // set error class to the control group
	            },
	            success: function (label) {
	                label.closest('.form-group').removeClass('has-error');
	                label.remove();
	            },
				errorPlacement: function(error, element) {  
				    error.appendTo(element.parent());  
				}
			}).form();			
		}
		
		function validateForm2() {
			//validate方法参数可选  
			return $("#caiGouForm").validate({
				errorElement: 'span', //default input error message container
	            errorClass: 'help-block', // default input error message class
	            focusInvalid: false, // do not focus the last invalid input
				rules : {
					tuJing : {
						required : true
					},
					jiaGe : {
						required : true,
						number : true
					}
				},
				messages : {					
					tuJing : {
						required : '请输入采购途径'
					},
					jiaGe : {
						required : '请输入价格',
						number : '请输入数值'
					}
				},
				highlight: function (element) { // hightlight error inputs
	                $(element)
	                    .closest('.form-group').addClass('has-error'); // set error class to the control group
	            },
	            success: function (label) {
	                label.closest('.form-group').removeClass('has-error');
	                label.remove();
	            },
				errorPlacement: function(error, element) {  
				    error.appendTo(element.parent());  
				}
			}).form();			
		}
		
		$('#tijiao').bind("click",function(){
			if(validateForm()){
				if(validateForm2()){
					$.ajax({
						type:"POST",
						data:$('#wuZiForm').serialize(),
						url:"${ctx}/wuzi/cgWuZiPLSave.do",
						dataType:"json",
						async:false,
						success:function(data){
							$('#wuZiIds').val(data.wuZiIds);
							$.ajax({
								type:"POST",
								url:"${ctx}/wuzi/caiGouPLSave.do",
								data:$('#caiGouForm').serialize(),
								dataType:"html",
								success:function(data){
									alert("您完成了该项采购！");
									$.ajax({
										type:"POST",
										url:"${ctx}/wuzi/cgspList.do",
										dataType:"html",
										success:function(data){
											window.opener.document.getElementById("cgsp").innerHTML = data;
											window.close();
										}
									});
								}
							});
						}
					});
				}
			}
		});
		
		$('#upHeTong').click(function(){
			$.ajax({
				type:"POST",
				url:"${ctx}/wuzi/upHeTongForm.do",
				data:{
					"otherId":"${shenQing.id}",
					"type":"0"
				},
				dataType:"html",
				async:false,
				success:function(data){
					$('#fileUploadBody').html(data);
					FormFileUpload.init();
				}
			});
		});
		
		$('#xzHeTong').click(function(){
			$.ajax({
				type:"POST",
				url:"${ctx}/wuzi/xzHeTongForm.do",
				data:{
					"type":"0"
				},
				dataType:"html",
				async:false,
				success:function(data){
					$('#fileListBody').html(data);
					//联动
					$('#fileName').keyup(function(){
						$.ajax({
							type:"POST",
							url:"${ctx}/wuzi/selFileList.do",
							data:{
								"type":"0",
								"fileName":$('#fileName').val()
							},
							dataType:"html",
							success:function(data){
								$('#yiXuanZe').html(data);
							}
						});
					});
				}
			});
		});
		
		$('#upFuJian').click(function(){
			$.ajax({
				type:"POST",
				url:"${ctx}/wuzi/upFuJianForm.do",
				data:{
					"otherId":"${shenQing.id}",
					"type":"2"
				},
				dataType:"html",
				async:false,
				success:function(data){
					$('#fileUploadBody').html(data);
					FormFileUpload.init();
				}
			});
		});
		
		$('#xzFuJian').click(function(){
			$.ajax({
				type:"POST",
				url:"${ctx}/wuzi/xzFuJianForm.do",
				data:{
					"type":"2"
				},
				dataType:"html",
				async:false,
				success:function(data){
					$('#fileListBody').html(data);
					
				}
			});
		});
		
		function upFuJian(id,ysWJM,type){
			if(type=="0"){
				var heTong=$('#heTong').val();
				heTong=heTong+id+",";
				$('#heTong').val(heTong);
				var result="<span id=\""+id+"\" style=\"font-size:14px\"><a href=\"${ctx }/wuzi/downloadFile.do?id="+id+"&type="+type+"\">"+ysWJM+"</a>&nbsp;&nbsp;<a href=\"javascript:delFuJian('"+id+"','"+type+"')\">X</a>&nbsp;&nbsp;</span>";
				$('#heTongList').append(result);
			}else if(type=="2"){
				var fuJian=$('#fuJian').val();
				fuJian=fuJian+id+",";
				$('#fuJian').val(fuJian);
				var result="<span id=\""+id+"\" style=\"font-size:14px\"><a href=\"${ctx }/wuzi/downloadFile.do?id="+id+"&type="+type+"\">"+ysWJM+"</a>&nbsp;&nbsp;<a href=\"javascript:delFuJian('"+id+"','"+type+"')\">X</a>&nbsp;&nbsp;</span>";
				$('#fuJianList').append(result);
			}
		}
		
		function delFuJian(id,type){
			if(type=="0"){
				var heTong=$('#heTong').val();
				heTong=heTong.replace(id+",","");
				$('#heTong').val(heTong);
				$('#'+id).remove();
				$.ajax({
					type:"POST",
					url:"${ctx}/wuzi/delFuJian.do",
					data:{
						"id":id,
						"type":"0"
					},
					dataType:"html",
					success:function(data){
						
					}
				});
			}else if(type=="2"){
				var fuJian=$('#fuJian').val();
				fuJian=fuJian.replace(id+",","");
				$('#fuJian').val(fuJian);
				$('#'+id).remove();
				$.ajax({
					type:"POST",
					url:"${ctx}/wuzi/delFuJian.do",
					data:{
						"id":id,
						"type":"2"
					},
					dataType:"html",
					success:function(data){
						
					}
				});
			}
		}
		
		function xuanZeQueDing(){
			var id=$('#yiXuanZe').val();
			var type=$('#xuanXeType').val();
			var ysWJM=$('#yiXuanZe').find("option:selected").text();
			if(type=="0"){
				var heTong=$('#heTong').val();
				heTong=heTong+id+",";
				$('#heTong').val(heTong);
				var result="<span id=\""+id+"\" style=\"font-size:14px\"><a href=\"${ctx }/wuzi/downloadFile.do?id="+id+"&type="+type+"\">"+ysWJM+"</a>&nbsp;&nbsp;<a href=\"javascript:delFuJian('"+id+"','"+type+"')\">X</a>&nbsp;&nbsp;</span>";
				$('#heTongList').append(result);
			}else if(type=="2"){
				var fuJian=$('#fuJian').val();
				fuJian=fuJian+id+",";
				$('#fuJian').val(fuJian);
				var result="<span id=\""+id+"\" style=\"font-size:14px\"><a href=\"${ctx }/wuzi/downloadFile.do?id="+id+"&type="+type+"\">"+ysWJM+"</a>&nbsp;&nbsp;<a href=\"javascript:delFuJian('"+id+"','"+type+"')\">X</a>&nbsp;&nbsp;</span>";
				$('#fuJianList').append(result);
			}
		}
		
		function chaKan(type){
			var id=$('#yiXuanZe').val();
			window.open("${ctx}/wuzi/downloadFile.do?id="+id+"&type="+type);
		}
	</script>
</body>
<!-- END BODY -->
</html>
